package net.sk.china.city.controller;

import net.sk.china.city.domain.ArUserApprove;
import net.sk.china.city.domain.dto.approve.ApproveQueryDTO;
import net.sk.china.city.domain.dto.approve.VolunteerApproveDTO;
import net.sk.china.city.service.IArUserApproveService;
import net.sk.china.city.controller.base.BaseController;
import net.sk.china.city.domain.dto.AjaxResult;
import net.sk.china.city.domain.dto.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 志愿者审核Controller
 * 
 * @author yangguanjin
 * @date 2024-04-17
 */
@Api(tags = "志愿者审核管理接口")
@RestController
@RequestMapping("/api/volunteer")
public class ArUserApproveController extends BaseController
{
    @Autowired
    private IArUserApproveService arUserApproveService;

    /**
     * 查询志愿者审核列表
     */
    @ApiOperation("列表")
    @PreAuthorize("hasAnyAuthority('user:volunteer:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApproveQueryDTO approveQuery)
    {
        startPage();
        List<ArUserApprove> list = arUserApproveService.selectArUserApproveList(approveQuery);
        return getDataTable(list);
    }

    /**
     * 导出志愿者审核列表
     */
//    @PreAuthorize("@ss.hasPermi('api:volunteer:export')")
//    @Log(title = "志愿者审核", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ApproveQueryDTO approveQuery)
//    {
//        List<ArUserApprove> list = arUserApproveService.selectArUserApproveList(approveQuery);
//        ExcelUtil<ArUserApprove> util = new ExcelUtil<ArUserApprove>(ArUserApprove.class);
//        util.exportExcel(response, list, "志愿者审核数据");
//    }

    /**
     * 获取志愿者审核详细信息
     */
    @ApiOperation("获取详情")
    @PreAuthorize("hasAnyAuthority('user:volunteer:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(arUserApproveService.selectArUserApproveByPkId(pkId));
    }

    /**
     * 新增志愿者审核
     */
//    @PreAuthorize("@ss.hasPermi('api:volunteer:add')")
//    @Log(title = "志愿者审核", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody ArUserApprove arUserApprove)
//    {
//        return toAjax(arUserApproveService.insertArUserApprove(arUserApprove));
//    }

    /**
     * 修改志愿者审核
     */
//    @PreAuthorize("@ss.hasPermi('api:volunteer:edit')")
//    @Log(title = "志愿者审核", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody ArUserApprove arUserApprove)
//    {
//        return toAjax(arUserApproveService.updateArUserApprove(arUserApprove));
//    }

    /**
     * 删除志愿者审核
     */
//    @PreAuthorize("@ss.hasPermi('api:volunteer:remove')")
//    @Log(title = "志愿者审核", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{pkIds}")
//    public AjaxResult remove(@PathVariable Long[] pkIds)
//    {
//        return toAjax(arUserApproveService.deleteArUserApproveByPkIds(pkIds));
//    }

    @ApiOperation("审核：通过")
    @PreAuthorize("hasAnyAuthority('user:volunteer:pass')")
    @PostMapping("/pass")
    public AjaxResult passApprove(@RequestBody VolunteerApproveDTO volunteerApprove) {
        int i = arUserApproveService.approveVolunteer(volunteerApprove);
        return success(i);
    }

    @ApiOperation("审核：拒绝")
    @PreAuthorize("hasAnyAuthority('user:volunteer:deny')")
    @PostMapping("/deny")
    public AjaxResult denyApprove(@RequestBody VolunteerApproveDTO volunteerApprove) {
        int i = arUserApproveService.denyVolunteer(volunteerApprove);
        return success(i);
    }
}
